﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Form01
{
    class DbHelper
    {
        public static readonly string conString = "server=.;database=Blogs;uid=SunBoy;pwd=010927";

        /// <summary>
        /// 查
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static DataTable GetDataTable(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(conString);
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql,sqlConnection);
            DataTable data = new DataTable();
            sqlConnection.Open();
            dataAdapter.Fill(data);
            return data;
        }
        public static int AddOrEditOrDeleteSave(string sql)
        {
            SqlConnection Connection = new SqlConnection(conString);
            SqlCommand sqlCommand = new SqlCommand(sql, Connection);
            Connection.Open();
            return sqlCommand.ExecuteNonQuery();
        }

    }
}
